;//
//  TimerLabel.m
//  倒计时
//
//  Created by MyMac on 15/9/28.
//  Copyright (c) 2015年 tongfang. All rights reserved.
//

#import "TimerLabel.h"
#import "TempTimertager.h"
@interface TimerLabel()
@property(nonatomic,weak)NSTimer*timer;

@end
@implementation TimerLabel


- (void)drawRect:(CGRect)rect {
    
}
-(void)startTimer
{
    self.enabled =YES;
    [self.timer invalidate];
    self.timer=nil;
    self.timer=[TempTimertager timerTagerTimeInterval:1.0 target:self selector:@selector(timerClick) userInfo:nil repeats:YES];
 
}
-(instancetype)initWithFrame:(CGRect)frame
{
    if ([super initWithFrame:frame]) {
    }
    return self;

}
-(void)endTimer
{

    [self.timer invalidate];
    self.timer=nil;

}

-(void)timerClick
{
    
    if (!self.time) {
        self.time=60;
    }
    if (self.time==0) {
        [self.timer invalidate];
        self.timer=nil;
    }
    
    [self setTitle:[NSString stringWithFormat:@"%ld",(long)self.time] forState:UIControlStateNormal];
    self.time--;
 

}
-(void)dealloc
{
    [self.timer invalidate];
    self.timer=nil;
    NSLog(@"timerLabel释放了");

}
@end
